<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/vhuichen.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/vhuichen.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/vhuichen.ico">
  <link rel="mask-icon" href="/vhuichen.ico" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"vhuichen.github.io","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.13.0","exturl":false,"sidebar":{"position":"left","display":"display","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}}</script><script src="/js/config.js"></script>

    <meta name="description" content="序言项目中，我用腾讯的 Bugly 作为项目统计和错误分析工具。一般在 Bugly 中分析出错堆栈时，用符号表可以更加精确的定位 bug 出现的地方。 什么是符号表符号表是内存地址与函数名、文件名、行号的映射表。格式如下：    &lt;起始地址&gt; &lt;结束地址&gt; &lt;函数&gt; [&lt;文件名:行号&gt;]    符号表的作用应用发生 crash 时的堆栈信息，一般都是">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS开发之符号表">
<meta property="og:url" content="https://vhuichen.github.io/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E7%AC%A6%E5%8F%B7%E8%A1%A8/index.html">
<meta property="og:site_name" content="vhuichen">
<meta property="og:description" content="序言项目中，我用腾讯的 Bugly 作为项目统计和错误分析工具。一般在 Bugly 中分析出错堆栈时，用符号表可以更加精确的定位 bug 出现的地方。 什么是符号表符号表是内存地址与函数名、文件名、行号的映射表。格式如下：    &lt;起始地址&gt; &lt;结束地址&gt; &lt;函数&gt; [&lt;文件名:行号&gt;]    符号表的作用应用发生 crash 时的堆栈信息，一般都是">
<meta property="og:locale">
<meta property="og:image" content="http://ovsbvt5li.bkt.clouddn.com/18-6-11/12282547.jpg">
<meta property="article:published_time" content="2018-06-07T16:00:00.000Z">
<meta property="article:modified_time" content="2018-07-29T14:46:50.890Z">
<meta property="article:author" content="vhuichen">
<meta property="article:tag" content="符号表">
<meta property="article:tag" content="Bugly">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://ovsbvt5li.bkt.clouddn.com/18-6-11/12282547.jpg">


<link rel="canonical" href="https://vhuichen.github.io/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E7%AC%A6%E5%8F%B7%E8%A1%A8/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-Hans","comments":true,"permalink":"https://vhuichen.github.io/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E7%AC%A6%E5%8F%B7%E8%A1%A8/","path":"2018/06/2018/06/iOS开发之符号表/","title":"iOS开发之符号表"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>iOS开发之符号表 | vhuichen</title>
  






  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">vhuichen</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">记录、分享</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section">Home</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section">Archives</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section">About</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BA%8F%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">序言</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E7%AC%A6%E5%8F%B7%E8%A1%A8"><span class="nav-number">1.1.</span> <span class="nav-text">什么是符号表</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AC%A6%E5%8F%B7%E8%A1%A8%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="nav-number">1.2.</span> <span class="nav-text">符号表的作用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AC%A6%E5%8F%B7%E8%A1%A8-UUID"><span class="nav-number">1.3.</span> <span class="nav-text">符号表 UUID</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#dSYM-%E6%96%87%E4%BB%B6"><span class="nav-number">1.4.</span> <span class="nav-text">dSYM 文件</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%97%AE%E9%A2%98%EF%BC%9A%E5%B7%B2%E7%BB%8F-release-%E7%9A%84%E7%89%88%E6%9C%AC%E6%80%8E%E6%A0%B7%E6%89%BE%E5%9B%9E-dSYM-%E6%96%87%E4%BB%B6%EF%BC%9F"><span class="nav-number">1.4.0.1.</span> <span class="nav-text">问题：已经 release 的版本怎样找回 dSYM 文件？</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%96%B9%E6%B3%951%EF%BC%9A"><span class="nav-number">1.4.0.1.1.</span> <span class="nav-text">方法1：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%96%B9%E6%B3%952%EF%BC%9A"><span class="nav-number">1.4.0.1.2.</span> <span class="nav-text">方法2：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E6%96%B9%E6%B3%953%EF%BC%9A"><span class="nav-number">1.4.0.1.3.</span> <span class="nav-text">方法3：</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B3%A8%E6%84%8F"><span class="nav-number">1.4.1.</span> <span class="nav-text">注意</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Bugly-%E8%84%9A%E6%9C%AC%E8%87%AA%E5%8A%A8%E4%B8%8A%E4%BC%A0-dSYM-%E6%96%87%E4%BB%B6"><span class="nav-number">1.5.</span> <span class="nav-text">Bugly 脚本自动上传 dSYM 文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%B3%A8%E6%84%8F-1"><span class="nav-number">1.5.1.</span> <span class="nav-text">注意</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%96%91%E9%97%AE"><span class="nav-number">1.6.</span> <span class="nav-text">疑问</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%99%84%E5%BD%95"><span class="nav-number">1.7.</span> <span class="nav-text">附录</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="vhuichen"
      src="/images/vhuichen.jpg">
  <p class="site-author-name" itemprop="name">vhuichen</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">78</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">11</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">86</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="Back to top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="https://vhuichen.github.io/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E7%AC%A6%E5%8F%B7%E8%A1%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/vhuichen.jpg">
      <meta itemprop="name" content="vhuichen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="vhuichen">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="iOS开发之符号表 | vhuichen">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          iOS开发之符号表
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Posted on</span>

      <time title="Created: 2018-06-08 00:00:00" itemprop="dateCreated datePublished" datetime="2018-06-08T00:00:00+08:00">2018-06-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">Edited on</span>
      <time title="Modified: 2018-07-29 22:46:50" itemprop="dateModified" datetime="2018-07-29T22:46:50+08:00">2018-07-29</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">In</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/iOS%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">iOS开发</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="序言"><a href="#序言" class="headerlink" title="序言"></a>序言</h1><p>项目中，我用腾讯的 Bugly 作为项目统计和错误分析工具。一般在 Bugly 中分析出错堆栈时，用符号表可以更加精确的定位 bug 出现的地方。</p>
<h2 id="什么是符号表"><a href="#什么是符号表" class="headerlink" title="什么是符号表"></a>什么是符号表</h2><p>符号表是内存地址与函数名、文件名、行号的映射表。格式如下：  </p>
<blockquote>
<p><strong>&lt;起始地址&gt; &lt;结束地址&gt; &lt;函数&gt; [&lt;文件名:行号&gt;]</strong>  </p>
</blockquote>
<h2 id="符号表的作用"><a href="#符号表的作用" class="headerlink" title="符号表的作用"></a>符号表的作用</h2><p>应用发生 crash 时的堆栈信息，一般都是二进制的地址信息。直接使用二进制信息很难定位问题，我们需要将这些二进制信息还原成代码所在的具体位置（哪个文件下，哪个方法，行号是多少）。有了这些信息，定位问题发生的位置就简单多了。这时候就需要符号表了。<br>符号表的作用就是：它能对 crash 的堆栈进行解析和还原，准确定位 APP 发生 crash 的地方。</p>
<h2 id="符号表-UUID"><a href="#符号表-UUID" class="headerlink" title="符号表 UUID"></a>符号表 UUID</h2><p>每打一个包，都会生成一个新的 UUID ，也就是说 <code>.app</code> <code>符号表</code> <code>dSYM</code> 文件拥有一个相同的 UUID 。当程序出现问题时，就是通过这个 UUID 找到对应的符号表的。</p>
<h2 id="dSYM-文件"><a href="#dSYM-文件" class="headerlink" title="dSYM 文件"></a>dSYM 文件</h2><p>dSYM 文件是指具有调试信息的目标文件，通过工具可以生成符号表文件。目前 Bugly 已经支持直接上传 dSYM 文件了。  </p>
<span id="more"></span>

<h4 id="问题：已经-release-的版本怎样找回-dSYM-文件？"><a href="#问题：已经-release-的版本怎样找回-dSYM-文件？" class="headerlink" title="问题：已经 release 的版本怎样找回 dSYM 文件？"></a>问题：已经 release 的版本怎样找回 dSYM 文件？</h4><h5 id="方法1："><a href="#方法1：" class="headerlink" title="方法1："></a>方法1：</h5><p>在 <code>Xcode -&gt; Window -&gt; Organizer</code>中找到相应的 <strong>.app</strong> 的位置，每一个 <strong>.app</strong> 都包含了相应的 dSYM 文件。在这个包里面找到dSYM 文件。</p>
<h5 id="方法2："><a href="#方法2：" class="headerlink" title="方法2："></a>方法2：</h5><p><code>在 iTunes Connect 的 &quot;所有构建版本&quot; 中可以找到。</code>   </p>
<h5 id="方法3："><a href="#方法3：" class="headerlink" title="方法3："></a>方法3：</h5><p>通过 mdfind 命令查找文件 </p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mdfind <span class="string">&quot;com_apple_xcode_dsym_uuids == &lt;UUID&gt;&quot;</span>  </span><br></pre></td></tr></table></figure>

<p>这里的 UUID 格式为 <code>|12345678-1234-1234-1234-xxxxxxxxxxxx|</code></p>
<h3 id="注意"><a href="#注意" class="headerlink" title="注意"></a>注意</h3><p>Debug 环境下默认没有生成 dSYM 文件，如果需要可以在项目中设置 <code>Target -&gt; Build Settings -&gt; Debug Information Format</code>，此外<code>Generate Debug Symbols</code>的值为<code>YES</code> 。</p>
<h2 id="Bugly-脚本自动上传-dSYM-文件"><a href="#Bugly-脚本自动上传-dSYM-文件" class="headerlink" title="Bugly 脚本自动上传 dSYM 文件"></a>Bugly 脚本自动上传 dSYM 文件</h2><p>下面是 Bugly 自动上传的脚本的一部分，主要修改这四个参数即可  </p>
<figure class="highlight objc"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">## Bugly 的 APP ID </span><br><span class="line">BUGLY_APP_ID=<span class="string">&quot;xxxxx&quot;</span></span><br><span class="line"></span><br><span class="line">## Bugly 的 APP KEY </span><br><span class="line">BUGLY_APP_KEY=<span class="string">&quot;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx&quot;</span></span><br><span class="line"></span><br><span class="line">## 应用的 bundle ID</span><br><span class="line">BUNDLE_IDENTIFIER=<span class="string">&quot;xxxx&quot;</span></span><br><span class="line"></span><br><span class="line"># Debug模式编译是否上传，<span class="number">1</span>＝上传 <span class="number">0</span>＝不上传，默认不上传</span><br><span class="line">UPLOAD_DEBUG_SYMBOLS=<span class="number">0</span></span><br></pre></td></tr></table></figure>

<p><img src="http://ovsbvt5li.bkt.clouddn.com/18-6-11/12282547.jpg">  </p>
<p>这种方法是所有方法中效率最高的。</p>
<h3 id="注意-1"><a href="#注意-1" class="headerlink" title="注意"></a>注意</h3><h2 id="疑问"><a href="#疑问" class="headerlink" title="疑问"></a>疑问</h2><p>1、在还没有使用自动上传 dSYM 文件之前，当在 Bugly 上发现崩溃问题时，我从 iTunes Connect 的构建版本中下载相应的 dSYM 文件，然后发现 UUID 是不相同的，这种情况是大都数都不相同，偶尔有几次却是可以的，无解。</p>
<h2 id="附录"><a href="#附录" class="headerlink" title="附录"></a>附录</h2><p><a target="_blank" rel="noopener" href="https://bugly.qq.com/docs/user-guide/symbol-configuration-ios/?v=20180521124306">Bugly iOS 符号表配置</a></p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E7%AC%A6%E5%8F%B7%E8%A1%A8/" rel="tag"># 符号表</a>
              <a href="/tags/Bugly/" rel="tag"># Bugly</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86/" rel="prev" title="iOS开发之加密解密">
                  <i class="fa fa-chevron-left"></i> iOS开发之加密解密
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2018/06/2018/06/iOS%E5%BC%80%E5%8F%91%E4%B9%8B%20CADisplayLink/" rel="next" title="iOS开发之 CADisplayLink">
                  iOS开发之 CADisplayLink <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2015 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vhuichen</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  





  





</body>
</html>
